package com.douyang.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.douyang.base.model.PageResult;
import com.douyang.dto.GetOrderStatementLogDTO;
import com.douyang.model.OrderStatementLog;
import com.douyang.mapper.OrderStatementLogMapper;
import com.douyang.service.OrderStatementLogService;
import com.douyang.vo.OrderStatementLogVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaoma
 * @since 2025-04-23
 */
@Service
public class OrderStatementLogServiceImpl extends ServiceImpl<OrderStatementLogMapper, OrderStatementLog> implements OrderStatementLogService {

    @Override
    public PageResult<OrderStatementLogVO> getOrderStatementLog(GetOrderStatementLogDTO getOrderStatementLogDTO) {
        Page<OrderStatementLog> page = lambdaQuery()
                .like(getOrderStatementLogDTO.getOrderStatementId() != null, OrderStatementLog::getOrderStatementId, getOrderStatementLogDTO.getOrderStatementId())
                .page(getOrderStatementLogDTO.getPage());

        return PageResult.of(page,orderStatementLog -> {
            OrderStatementLogVO orderStatementLogVO = new OrderStatementLogVO();
            BeanUtils.copyProperties(orderStatementLog, orderStatementLogVO);
            return orderStatementLogVO;
        });
    }
}
